1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgTabArray; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gobject.ObjectG; 31 private import linker.Loader; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * A `PangoTabArray` contains an array of tab stops. 38 * 39 * `PangoTabArray` can be used to set tab stops in a `PangoLayout`. 40 * Each tab stop has an alignment, a position, and optionally 41 * a character to use as decimal point. 42 */ 43 public class PgTabArray 44 { 45 /** the main Gtk struct */ 46 protected PangoTabArray* pangoTabArray; 47 protected bool ownedRef; 48 49 /** Get the main Gtk struct */ 50 public PangoTabArray* getPgTabArrayStruct(bool transferOwnership = false) 51 { 52 if (transferOwnership) 53 ownedRef = false; 54 return pangoTabArray; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected void* getStruct() 59 { 60 return cast(void*)pangoTabArray; 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (PangoTabArray* pangoTabArray, bool ownedRef = false) 67 { 68 this.pangoTabArray = pangoTabArray; 69 this.ownedRef = ownedRef; 70 } 71 72 ~this () 73 { 74 if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef ) 75 pango_tab_array_free(pangoTabArray); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return pango_tab_array_get_type(); 83 } 84 85 /** 86 * Creates an array of @initial_size tab stops. 87 * 88 * Tab stops are specified in pixel units if @positions_in_pixels is %TRUE, 89 * otherwise in Pango units. All stops are initially at position 0. 90 * 91 * Params: 92 * initialSize = Initial number of tab stops to allocate, can be 0 93 * positionsInPixels = whether positions are in pixel units 94 * 95 * Returns: the newly allocated `PangoTabArray`, which should 96 * be freed with [method@Pango.TabArray.free]. 97 * 98 * Throws: ConstructionException GTK+ fails to create the object. 99 */ 100 public this(int initialSize, bool positionsInPixels) 101 { 102 auto __p = pango_tab_array_new(initialSize, positionsInPixels); 103 104 if(__p is null) 105 { 106 throw new ConstructionException("null returned by new"); 107 } 108 109 this(cast(PangoTabArray*) __p); 110 } 111 112 /** 113 * Copies a `PangoTabArray`. 114 * 115 * Returns: the newly allocated `PangoTabArray`, which should 116 * be freed with [method@Pango.TabArray.free]. 117 */ 118 public PgTabArray copy() 119 { 120 auto __p = pango_tab_array_copy(pangoTabArray); 121 122 if(__p is null) 123 { 124 return null; 125 } 126 127 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) __p, true); 128 } 129 130 /** 131 * Frees a tab array and associated resources. 132 */ 133 public void free() 134 { 135 pango_tab_array_free(pangoTabArray); 136 ownedRef = false; 137 } 138 139 /** 140 * Gets the Unicode character to use as decimal point. 141 * 142 * This is only relevant for tabs with %PANGO_TAB_DECIMAL alignment, 143 * which align content at the first occurrence of the decimal point 144 * character. 145 * 146 * The default value of 0 means that Pango will use the 147 * decimal point according to the current locale. 148 * 149 * Params: 150 * tabIndex = the index of a tab stop 151 * 152 * Since: 1.50 153 */ 154 public dchar getDecimalPoint(int tabIndex) 155 { 156 return pango_tab_array_get_decimal_point(pangoTabArray, tabIndex); 157 } 158 159 /** 160 * Returns %TRUE if the tab positions are in pixels, 161 * %FALSE if they are in Pango units. 162 * 163 * Returns: whether positions are in pixels. 164 */ 165 public bool getPositionsInPixels() 166 { 167 return pango_tab_array_get_positions_in_pixels(pangoTabArray) != 0; 168 } 169 170 /** 171 * Gets the number of tab stops in @tab_array. 172 * 173 * Returns: the number of tab stops in the array. 174 */ 175 public int getSize() 176 { 177 return pango_tab_array_get_size(pangoTabArray); 178 } 179 180 /** 181 * Gets the alignment and position of a tab stop. 182 * 183 * Params: 184 * tabIndex = tab stop index 185 * alignment = location to store alignment 186 * location = location to store tab position 187 */ 188 public void getTab(int tabIndex, out PangoTabAlign alignment, out int location) 189 { 190 pango_tab_array_get_tab(pangoTabArray, tabIndex, &alignment, &location); 191 } 192 193 /** 194 * If non-%NULL, @alignments and @locations are filled with allocated 195 * arrays. 196 * 197 * The arrays are of length [method@Pango.TabArray.get_size]. 198 * You must free the returned array. 199 * 200 * Params: 201 * alignments = location to store an array of tab 202 * stop alignments 203 * locations = location to store an array 204 * of tab positions 205 */ 206 public void getTabs(out PangoTabAlign* alignments, out int[] locations) 207 { 208 int* outlocations; 209 210 pango_tab_array_get_tabs(pangoTabArray, &alignments, &outlocations); 211 212 locations = outlocations[0 .. getArrayLength(outlocations)]; 213 } 214 215 /** 216 * Resizes a tab array. 217 * 218 * You must subsequently initialize any tabs 219 * that were added as a result of growing the array. 220 * 221 * Params: 222 * newSize = new size of the array 223 */ 224 public void resize(int newSize) 225 { 226 pango_tab_array_resize(pangoTabArray, newSize); 227 } 228 229 /** 230 * Sets the Unicode character to use as decimal point. 231 * 232 * This is only relevant for tabs with %PANGO_TAB_DECIMAL alignment, 233 * which align content at the first occurrence of the decimal point 234 * character. 235 * 236 * By default, Pango uses the decimal point according 237 * to the current locale. 238 * 239 * Params: 240 * tabIndex = the index of a tab stop 241 * decimalPoint = the decimal point to use 242 * 243 * Since: 1.50 244 */ 245 public void setDecimalPoint(int tabIndex, dchar decimalPoint) 246 { 247 pango_tab_array_set_decimal_point(pangoTabArray, tabIndex, decimalPoint); 248 } 249 250 /** 251 * Sets whether positions in this array are specified in 252 * pixels. 253 * 254 * Params: 255 * positionsInPixels = whether positions are in pixels 256 * 257 * Since: 1.50 258 */ 259 public void setPositionsInPixels(bool positionsInPixels) 260 { 261 pango_tab_array_set_positions_in_pixels(pangoTabArray, positionsInPixels); 262 } 263 264 /** 265 * Sets the alignment and location of a tab stop. 266 * 267 * Params: 268 * tabIndex = the index of a tab stop 269 * alignment = tab alignment 270 * location = tab location in Pango units 271 */ 272 public void setTab(int tabIndex, PangoTabAlign alignment, int location) 273 { 274 pango_tab_array_set_tab(pangoTabArray, tabIndex, alignment, location); 275 } 276 277 /** 278 * Utility function to ensure that the tab stops are in increasing order. 279 * 280 * Since: 1.50 281 */ 282 public void sort() 283 { 284 pango_tab_array_sort(pangoTabArray); 285 } 286 287 /** 288 * Serializes a `PangoTabArray` to a string. 289 * 290 * No guarantees are made about the format of the string, 291 * it may change between Pango versions. 292 * 293 * The intended use of this function is testing and 294 * debugging. The format is not meant as a permanent 295 * storage format. 296 * 297 * Returns: a newly allocated string 298 * 299 * Since: 1.50 300 */ 301 public override string toString() 302 { 303 auto retStr = pango_tab_array_to_string(pangoTabArray); 304 305 scope(exit) Str.freeString(retStr); 306 return Str.toString(retStr); 307 } 308 309 /** 310 * Deserializes a `PangoTabArray` from a string. 311 * 312 * This is the counterpart to [method@Pango.TabArray.to_string]. 313 * See that functions for details about the format. 314 * 315 * Params: 316 * text = a string 317 * 318 * Returns: a new `PangoTabArray` 319 * 320 * Since: 1.50 321 */ 322 public static PgTabArray fromString(string text) 323 { 324 auto __p = pango_tab_array_from_string(Str.toStringz(text)); 325 326 if(__p is null) 327 { 328 return null; 329 } 330 331 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) __p, true); 332 } 333 }